import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, ObjectId } from 'mongoose';
import { Role } from '@common/role';
import { ApiProperty } from '@nestjs/swagger';
export type UserDocument = User & Document;
export enum Gender {
    unknown,
    mam,
    woman,
}
@Schema()
export class User {
    @ApiProperty({ type: String })
    _id: ObjectId;
    /**
     * 用户名
     */
    @Prop({
        index: true,
        unique: true,
        required: true,
    })
    username: string;
    /**
     * 密码
     */
    @Prop({
        required: true,
    })
    password: string;
    /**
     * 手机号
     */
    @Prop({
        default: '',
        // unique: true,
    })
    phone: string;
    /**
     * 头像
     */
    @Prop({
        default: '',
    })
    avatar: string;
    /**
     * 昵称
     */
    @Prop({
        default: '',
    })
    nickname: string;
    /**
     * 签名
     */
    @Prop({
        default: '',
    })
    desc: string;
    /**
     * 创建时间
     */
    @Prop({
        default: Date.now,
    })
    createdAt: Date;
    /**
     * 修改时间
     */
    @Prop({
        default: Date.now,
    })
    updatedAt: Date;
    /**
     * 性别
     */
    @Prop({
        default: Gender.unknown,
    })
    gender: Gender;
    /**
     * 生日
     */
    @Prop({
        default: null,
    })
    birthday: Date;
    /**
     * 角色
     */
    @Prop({
        default: Role.User,
    })
    roles: Role[];
}

export const UserSchema = SchemaFactory.createForClass(User);
